#include<iostream>
#include<string>
#include<cstdio>
using namespace std;
typedef long long LL;
const int N = 1e5 + 10;
int arr[N];
LL l[N], r[N];
int n;
int main()
{
    scanf("%d", &n);
    for (int i = 1; i <= n; i++) {
        scanf("%d", &arr[i]);
    }
    for (int i = 1; i <= n; i++) {
        l[i] = 1;
        for (int j = 1; j < i; j++) {
            if (arr[i] > arr[j]) {
                l[i] = max(l[i], l[j] + 1);
            }
        }
    }
    for (int i = n; i; i--) {
        r[i] = 1;
        for (int j = n; j > i; j--) {
            if (arr[i] > arr[j]) {
                r[i] = max(r[i], r[j] + 1);
            }
        }
    }
    LL ans = 0;
    for (int i = 1; i <= n; i++) {
        cout << l[i] << " " << r[i] << endl;
        ans = max(ans, l[i] + r[i]);
    }
    cout << n - ans << endl;
    return 0;
}